Chris Pollett > Old Classses >
CS146

( Print View )

Student Corner:
  [Grades Sec5]
  [Grades Sec6]
  [Submit Sec5]
  [Submit Sec6]

  [
Lecture Notes]
  [Discussion Board]

Course Info:
  [Texts & Links]
  [Topics/Outcomes]
  [Outcomes Matrix]
  [Grading]
  [Class Protocols]
  [HW/Quiz Info]
  [Exam Info]
  [Regrades]
  [Honesty]
  [Additional Policies]
  [Announcements]

HW Assignments:
  [Hw1]  [Hw2]  [Hw3]
  [Hw4]  [Hw5]  [Quizzes]

Practice Exams:
  [Midterm]  [Final]

                           












CS146 Spring 2014Practice Midterm

To study for the midterm I would suggest you: (1) Know how to do (by heart) all the practice problems. (2) Go over your notes at least three times. Second and third time try to see how much you can remember from the first time. (3) Go over the homework problems. (4) Try to create your own problems similar to the ones I have given and solve them. (5) Skim the relevant sections from the book. (6) If you want to study in groups, at this point you are ready to quiz each other. The practice midterm is below. Here are some facts about the actual midterm: (a) It is closed book, closed notes. Nothing will be permitted on your desk except your pen (pencil) and test. (b) You should bring photo ID. (c) There will be more than one version of the test. Each version will be of comparable difficulty. (d) One problem (less typos) on the actual test will be from the practice test.

  1. Show step-by-step how insertion sort would sort the array `[10, 7, 12, 6, 9]`.
  2. Assume all numbers to be sorted are drawn uniformly at random from a set of integer 1,2,..,k. Prove that the expected running time of insertion sort on these inputs is `Theta(n^2)`.
  3. Prove that MERGE-SORT is a divide and conquer algorithm. Prove that the MERGE operation operation satisfies the loop invariant:

    At the start of each iteration of the for loop of lines 12-17, the subarray `A[p..k-1]` contains the k - p smallest elements of `L[1..n1 + 1]` and `R[1..n2 + 1]` in sorted order. Moreover, `L[i]` and `R[j]` are the smallest elements of their arrays that have not been copied back to `A`.

  4. Show each of the following carefully (a) `log log n in o(log n)`, (b) `n! in omega(n^(1000))`.
  5. Give with proof a tight bound for the recurrence `T(n) = 4T(lfloor n/3 rfloor + 9) + n^2`.
  6. Show step-by-step how the BUILD-HEAP procedure would build a heap from the array `[10, 7, 12, 6, 9]`.
  7. Give an outline of the proof that RANDOMIZED-QUICKSORT has expected running time `O(n log n)`.
  8. Assume all inputs to a counting sort algorithm are in the range 0 to 7. Show how counting sort would sort `[1, 7, 5, 6, 3]`.
  9. Give an outline of the proof that BUCKET_SORT has expected running time `Theta(n)`.
  10. Give pseudo-code for the RANDOMIZED-SELECT procedure.